package creditnum;

public class UnderDHood {
	private CreditData creditData;

	UnderDHood() {
		creditData = new CreditData();
	}

	public String mostCommonNumber() {
		String common = "All are met only once.";
		int br;
		int mostbr = 1;
		for (int i = 0; i < creditData.getLength(); i++) {
			br = 0;
			for (int j = 0; j < creditData.getLength(); j++) {
				if (creditData.getCardNumber(i).equals(
						creditData.getCardNumber(j))) {
					br++;
					if (mostbr < br) {
						mostbr = br;
						common = creditData.getCardNumber(i);

					}
				}
			}
		}
		return common;
	}

	// getters and setters
	public void setCardNumber(String cardNumber) {
		creditData.setCardNumber(cardNumber);
	}

	public String getCardNumber(int cardPosition) {
		return creditData.getCardNumber(cardPosition);
	}

	public int getLength() {
		return creditData.getLength();
	}
}
